﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1050004, 0),
Array("", 1050012, 0),
Array("", 1050013, 0),
Array("", 1050014, 0),
Array("", 1050015, 0),
Array("", 1050016, 0),
Array("", 1050017, 0),
Array("", 1050019, 0),
Array("", 1050020, 0),
Array("", 1050032, 0),
Array("", 1050033, 0),
Array("", 1050034, 0),
Array("", 1050040, 0),
Array("", 1050041, 0),
Array("", 1050042, 0),
Array("", 1050043, 0),
Array("", 1050044, 0),
Array("", 1050050, 0),
Array("", 1050057, 0),
Array("", 1050065, 0),
Array("", 1050066, 0),
Array("", 1050071, 0),
Array("", 1050079, 0),
Array("", 1050084, 0),
Array("", 1050085, 0),
Array("", 1050086, 0),
Array("", 1050087, 0),
Array("", 1050101, 0),
Array("", 1050109, 0),
Array("", 1050110, 0),
Array("", 1050111, 0),
Array("", 1050112, 0),
Array("", 1050113, 0),
Array("", 1050114, 0),
Array("", 1050115, 0),
Array("", 1050116, 0),
Array("", 1050117, 0),
Array("", 1050118, 0),
Array("", 1050119, 0),
Array("", 1050120, 0),
Array("", 1050121, 0),
Array("", 1050123, 0),
Array("", 1050124, 0),
Array("", 1050125, 0),
Array("", 1050126, 0),
Array("", 1050128, 0),
Array("", 1050129, 0),
Array("", 1050135, 0),
Array("", 1050136, 0),
Array("", 1050137, 0),
Array("", 1050138, 0),
Array("", 1050139, 0),
Array("", 1050141, 0),
Array("", 1050142, 0),
Array("", 1050143, 0),
Array("", 1050145, 0),
Array("", 1050146, 0),
Array("", 1050147, 0),
Array("", 1050148, 0),
Array("", 1050149, 0),
Array("", 1050150, 0),
Array("", 1050151, 0),
Array("", 1050152, 0),
Array("", 1050153, 0),
Array("", 1050154, 0),
Array("", 1050156, 0),
Array("", 1050161, 0),
Array("", 1050168, 0),
Array("", 1050170, 0),
Array("", 1050177, 0),
Array("", 1050178, 0),
Array("", 1050179, 0),
Array("", 1050180, 0),
Array("", 1050186, 0),
Array("", 1050187, 0),
Array("", 1050188, 0),
Array("", 1050190, 0),
Array("", 1050193, 0),
Array("", 1050208, 0),
Array("", 1050209, 0),
Array("", 1050210, 0),
Array("", 1050215, 0),
Array("", 1050220, 0),
Array("", 1050221, 0),
Array("", 1050226, 0),
Array("", 1050227, 0),
Array("", 1050228, 0),
Array("", 1050229, 0),
Array("", 1050230, 0),
Array("", 1050231, 0),
Array("", 1050232, 0),
Array("", 1050234, 0),
Array("", 1050235, 0),
Array("", 1050242, 0),
Array("", 1050243, 0),
Array("", 1050244, 0),
Array("", 1051002, 0),
Array("", 1051018, 0),
Array("", 1051019, 0),
Array("", 1051020, 0),
Array("", 1051021, 0),
Array("", 1051022, 0),
Array("", 1051028, 0),
Array("", 1051029, 0),
Array("", 1051035, 0),
Array("", 1051036, 0),
Array("", 1051040, 0),
Array("", 1051048, 0),
Array("", 1051049, 0),
Array("", 1051050, 0),
Array("", 1051051, 0),
Array("", 1051059, 0),
Array("", 1051060, 0),
Array("", 1051061, 0),
Array("", 1051070, 0),
Array("", 1051071, 0),
Array("", 1051072, 0),
Array("", 1051073, 0),
Array("", 1051074, 0),
Array("", 1051075, 0),
Array("", 1051076, 0),
Array("", 1051081, 0),
Array("", 1051086, 0),
Array("", 1051087, 0),
Array("", 1051088, 0),
Array("", 1051089, 0),
Array("", 1051099, 0),
Array("", 1051100, 0),
Array("", 1051108, 0),
Array("", 1051109, 0),
Array("", 1051110, 0),
Array("", 1051111, 0),
Array("", 1051112, 0),
Array("", 1051113, 0),
Array("", 1051114, 0),
Array("", 1051115, 0),
Array("", 1051116, 0),
Array("", 1051117, 0),
Array("", 1051118, 0),
Array("", 1051119, 0),
Array("", 1051120, 0),
Array("", 1051121, 0),
Array("", 1051122, 0),
Array("", 1051123, 0),
Array("", 1051124, 0),
Array("", 1051125, 0),
Array("", 1051126, 0),
Array("", 1051127, 0),
Array("", 1051128, 0),
Array("", 1051129, 0),
Array("", 1051131, 0),
Array("", 1051132, 0),
Array("", 1051133, 0),
Array("", 1051134, 0),
Array("", 1051135, 0),
Array("", 1051136, 0),
Array("", 1051137, 0),
Array("", 1051138, 0),
Array("", 1051139, 0),
Array("", 1051141, 0),
Array("", 1051142, 0),
Array("", 1051143, 0),
Array("", 1051144, 0),
Array("", 1051145, 0),
Array("", 1051146, 0),
Array("", 1051147, 0),
Array("", 1051149, 0),
Array("", 1051154, 0),
Array("", 1051155, 0),
Array("", 1051156, 0),
Array("", 1051157, 0),
Array("", 1051158, 0),
Array("", 1051159, 0),
Array("", 1051160, 0),
Array("", 1051162, 0),
Array("", 1051163, 0),
Array("", 1051164, 0),
Array("", 1051166, 0),
Array("", 1051167, 0),
Array("", 1051170, 0),
Array("", 1051171, 0),
Array("", 1051173, 0),
Array("", 1051175, 0),
Array("", 1051176, 0),
Array("", 1051177, 0),
Array("", 1051178, 0),
Array("", 1051179, 0),
Array("", 1051180, 0),
Array("", 1051182, 0),
Array("", 1051183, 0),
Array("", 1051185, 0),
Array("", 1051188, 0),
Array("", 1051189, 0),
Array("", 1051190, 0),
Array("", 1051192, 0),
Array("", 1051193, 0),
Array("", 1051199, 0),
Array("", 1051200, 0),
Array("", 1051208, 0),
Array("", 1051209, 0),
Array("", 1051211, 0),
Array("", 1051218, 0),
Array("", 1051219, 0),
Array("", 1051220, 0),
Array("", 1051221, 0),
Array("", 1051227, 0),
Array("", 1051228, 0),
Array("", 1051229, 0),
Array("", 1051231, 0),
Array("", 1051232, 0),
Array("", 1051233, 0),
Array("", 1051235, 0),
Array("", 1051238, 0),
Array("", 1051252, 0),
Array("", 1051253, 0),
Array("", 1051254, 0),
Array("", 1051255, 0),
Array("", 1051256, 0),
Array("", 1051261, 0),
Array("", 1051262, 0),
Array("", 1051264, 0),
Array("", 1051265, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚套服店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}